package com.zyh.day05.operator

import org.apache.spark.sql.{DataFrame, Dataset, Row, SparkSession}

object LimitTest {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder()
      .master("local[*]")
      .appName("lt")
      .getOrCreate()

    val list = List((1, "xiao1hei", 18, "F",2000.0), (2, "xiao2hei", 18, "F",4000.0), (3, "xiao3hei", 20, "M",2000.0), (4, "xiao4hei", 22, "M",3000.0))

    import spark.implicits._
    val df: DataFrame = list.toDF("uid", "name", "age", "sex","salary")

//    val result: Array[Row] = df.collect()
//    val result: Dataset[Row] = df.limit(2)
//    result.foreach(println)
//    result.show()
    spark.close()

  }
}
